home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
gnumake
/
make360.zoo
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-07
|
34KB
|
1,365 lines
/* Copyright (C) 1988-1991 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GNU Make is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Make; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "make.h"
#include "commands.h"
#include "dep.h"
#include "file.h"
#include "variable.h"
#include "job.h"
#include <ctype.h>
#include <time.h>
extern char *version_string;
extern int fatal_error_signal ();
extern struct dep *read_all_makefiles ();
extern void print_variable_data_base ();
extern void print_dir_data_base ();
extern void print_rule_data_base ();
extern void print_file_data_base ();
extern void print_vpath_data_base ();
#if !defined(__GNU_LIBRARY__) && !defined(_POSIX_SOURCE)
extern int chdir ();
extern void exit ();
extern time_t time ();
extern double atof ();
#endif
extern char *mktemp ();
static void log_working_directory ();
static void print_data_base (), print_version ();
static void decode_switches (), decode_env_switches ();
static void define_makeflags ();
#if 0 /* dummy tag */
flags () {}
#endif
/* Flags:
* -b ignored for compatibility with System V Make
* -C change directory
* -d debug
* -e env_overrides
* -f makefile
* -i ignore_errors
* -j job_slots
* -k keep_going
* -l max_load_average
* -m ignored for compatibility with something or other
* -n just_print
* -o consider file old
* -p print_data_base
* -q question
* -r no_builtin_rules
* -s silent
* -S turn off -k
* -t touch
* -v print version information
* -w log working directory
* -W consider file new (with -n, `what' if effect)
*/
/* The structure that describes an accepted command switch. */
struct command_switch
{
char c; /* The switch character. */
enum /* Type of the value. */
{
flag, /* Turn int flag on. */
flag_off, /* Turn int flag off. */
string, /* One string per switch, may be in the same word. */
positive_int, /* A positive integer. */
floating, /* A floating-point number (double). */
ignore /* Ignored. */
} type;
char *value_ptr; /* Pointer to the value-holding variable. */
unsigned int env:1; /* Can come from MAKEFLAGS. */
unsigned int toenv:1; /* Should be put in MAKEFLAGS. */
unsigned int no_makefile:1; /* Don't propagate when remaking makefiles. */
char *noarg_value; /* Pointer to value used if no argument is given. */
char *default_value;/* Pointer to default value. */
};
/* The structure used to hold the list of strings given
in command switches of a type that takes string arguments. */
struct stringlist
{
char **list; /* Nil-terminated list of strings. */
unsigned int idx; /* Index into above. */
unsigned int max; /* Number of pointers allocated. */
};
/* The recognized command switches. */
/* Nonzero means do not print commands to be executed (-s). */
int silent_flag;
/* Nonzero means just touch the files
that would appear to need remaking (-t) */
int touch_flag;
/* Nonzero means just print what commands would need to be executed,
don't actually execute them (-n). */
int just_print_flag;
/* Print debugging trace info (-d). */
int debug_flag = 0;
/* Environment variables override makefile definitions. */
int env_overrides = 0;
/* Nonzero means ignore status codes returned by commands
executed to remake files. Just treat them all as successful (-i). */
int ignore_errors_flag = 0;
/* Nonzero means don't remake anything, just print the data base
that results from reading the makefile (-p). */
int print_data_base_flag = 0;
/* Nonzero means don't remake anything; just return a nonzero status
if the specified targets are not up to date (-q). */
int question_flag = 0;
/* Nonzero means do not use any of the builtin rules (-r). */
int no_builtin_rules_flag = 0;
/* Nonzero means keep going even if remaking some file fails (-k). */
int keep_going_flag;
int default_keep_going_flag = 0;
/* Nonzero means print working directory
before starting and after finishing make. */
int print_directory_flag = 0;
/* Nonzero means print version information. */
int print_version_flag = 0;
/* List of makefiles given with -f switches. */
static struct stringlist *makefiles = 0;
/* Number of job slots (commands that can be run at once). */
unsigned int job_slots = 1;
unsigned int default_job_slots = 1;
/* Value of job_slots that means no limit. */
static unsigned int inf_jobs = 0;
/* Maximum load average at which multiple jobs will be run.
Negative values mean unlimited, while zero means limit to
zero load (which could be useful to start infinite jobs remotely
but one at a time locally). */
double max_load_average = -1.0;
double default_load_average = -1.0;
/* List of directories given with -c switches. */
static struct stringlist *directories = 0;
/* List of include directories given with -I switches. */
static struct stringlist *include_directories = 0;
/* List of files given with -o switches. */
static struct stringlist *old_files = 0;
/* List of files given with -W switches. */
static struct stringlist *new_files = 0;
/* The table of command switches. */
static struct command_switch switches[] =
{
{ 'b', ignore, 0, 0, 0, 0, 0, 0 },
{ 'C', string, (char *) &directories, 0, 0, 0, 0, 0 },
{ 'd', flag, (char *) &debug_flag, 1, 1, 0, 0, 0 },
{ 'e', flag, (char *) &env_overrides, 1, 1, 0, 0, 0 },
{ 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0 },
{ 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0 },
{ 'I', string, (char *) &include_directories, 0, 0, 0, 0, 0 },
{ 'j', positive_int, (char *) &job_slots, 1, 1, 0,
(char *) &inf_jobs, (char *) &default_job_slots },
{ 'k', flag, (char *) &keep_going_flag, 1, 1, 0,
0, (char *) &default_keep_going_flag },
{ 'l', floating, (char *) &max_load_average, 1, 1, 0,
(char *) &default_load_average, (char *) &default_load_average },
{ 'm', ignore, 0, 0, 0, 0, 0, 0 },
{ 'n', flag, (char *) &just_print_flag, 1, 1, 1, 0, 0 },
{ 'o', string, (char *) &old_files, 0, 0, 0, 0, 0 },
{ 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0 },
{ 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0 },
{ 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0 },
{ 's', flag, (char *) &silent_flag, 1, 1, 0, 0, 0 },
{ 'S', flag_off, (char *) &keep_going_flag, 1, 1, 0,
0, (char *) &default_keep_going_flag },
{ 't', flag, (char *) &touch_flag, 1, 1, 1, 0, 0 },
{ 'v', flag, (char *) &print_version_flag, 0, 0, 0, 0, 0 },
{ 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0 },
{ 'W', string, (char *) &new_files, 0, 0, 0, 0, 0 },
{ '\0', ignore, 0, 0, 0, 0, 0 }
};
/* List of non-switch arguments. */
struct stringlist *other_args = 0;
/* The name we were invoked with. */
char *program;
/* Value of the MAKELEVEL variable at startup (or 0). */
unsigned int makelevel;
/* First file defined in the makefile whose name does not
start with `.'. This is the default to remake if the
command line does not specify. */
struct file *default_goal_file;
/* Pointer to structure for the file .DEFAULT
whose commands are used for any file that has none of its own.
This is zero if the makefiles do not define .DEFAULT. */
struct file *default_file;
/* Mask of signals that are being caught with fatal_error_signal. */
int fatal_signal_mask;
int
main (argc, argv, envp)
int argc;
char **argv;
char **envp;
{
#if (defined(USG) && !defined(HAVE_SIGLIST)) || defined(DGUX)
extern void init_siglist ();
#endif
extern int child_handler ();
register struct file